const ApiError = require('../error/api_error');
const ApiErrorNames = require('../error/api_error_name');
const ApiErrorMap = require('../error/api_error_map');

//只对api前缘路由执行
const responseFormatter = (apiPrefix) => async (ctx, next) => {

  if (ctx.request.path.startsWith(apiPrefix)) {
    if (ctx.status === 404) {

      return
    } else {
      await next()
    }
  } else {
    await next();
  }
};

module.exports = responseFormatter;
